package com.fys.order.controller;

import com.fys.order.dto.OrderDTO;
import com.fys.order.message.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class SendMessageController {
    @Autowired
    private StreamClient streamClient;

    /**
     * @Description: 发送字符串
     */
    @GetMapping("/sendMessage")
    public void sendMessage(){
        streamClient.output().send(MessageBuilder.withPayload("now " + new Date()).build());
    }


    /**
    * @Description: 发送对象
    */
    @GetMapping("/sendMessageObj")
    public void sendMessageObj(){
        OrderDTO orderDTO = new OrderDTO();
        orderDTO.setOrderId("1111111");
        streamClient.output().send(MessageBuilder.withPayload(orderDTO).build());
    }


}
